import { presetIcons, presetUno } from 'unocss'
import { presetScrollbar } from 'unocss-preset-scrollbar'
import { FileSystemIconLoader } from '@iconify/utils/lib/loader/node-loaders'

const resolveIcon = (path: string) => {
  return () => import(`@iconify-json/${path}/icons.json`).then(i => i.default)
}

export default [
  presetUno({ dark: 'class' }),
  presetIcons({
    prefix: 'i-',
    scale: 1,
    extraProperties: {
      display: 'inline-block',
      'vertical-align': 'middle',
    },
    collections: {
      mdi: resolveIcon('mdi'),
      bi: resolveIcon('bi'),
      tb: resolveIcon('token-branded'),
      local: FileSystemIconLoader('./src/styles/icons'),
    },
    warn: true,
  }),
  presetScrollbar({
    noCompatible: true,
    scrollbarWidth: '10px',
    scrollbarHeight: '10px',
    scrollbarTrackRadius: '5px',
    scrollbarThumbRadius: '5px',
  }),
]
